﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Communication.Common
{
    public class EventMessageManager
    {
        private static EventMessageManager currentEventMessageManager;
        private Queue<EventMessage> receivedMessageQueue;
        private Queue<EventMessage> sentMessageQueue;
        private EventMessageManager() 
        {
            receivedMessageQueue = new Queue<EventMessage>();
            sentMessageQueue = new Queue<EventMessage>();
        }

        static EventMessageManager()
        {
            currentEventMessageManager = new EventMessageManager();
        }

        public static EventMessageManager CurrentEventMessageManager
        {
            get
            {
                return currentEventMessageManager;
            }
        }

        public EventMessage GetReceivedEventMessage()
        {
            if (receivedMessageQueue.Count == 0)
                return null;
            return receivedMessageQueue.Dequeue();
        }

        public void AddReceivedEventMessage(EventMessage msg)
        {
            receivedMessageQueue.Enqueue(msg);
        }

        public EventMessage GetSentEventMessage()
        {
            if (sentMessageQueue.Count == 0)
                return null;
            return sentMessageQueue.Dequeue();
        }

        public void AddSentEventMessage(EventMessage msg)
        {
            sentMessageQueue.Enqueue(msg);
        }
    }
}
